import { Injectable } from '@angular/core';
import { AngularFireDatabase, AngularFireList } from '@angular/fire/compat/database';
import { Elem } from './elem';

@Injectable({
  providedIn: 'root'
})
export class AdatokService {
  private dbPath:string="/alkatreszek";
  alkatreszekRef: AngularFireList<Elem>;
  
  constructor(private db:AngularFireDatabase) {
    this.alkatreszekRef=db.list(this.dbPath);
  }

  getAllAdatok(){
    return this.alkatreszekRef;
  }

  pushAdatok(value:any){
    return this.alkatreszekRef.push(value);
  }

  updateAdatok(key:string, value:any){
    return this.alkatreszekRef.update(key, value);
  }

  deleteAdatok(key:string){
    return this.alkatreszekRef.remove(key);
  }

  deleteAllAdatok(){
    return this.alkatreszekRef.remove();
  }

  //Saját függvények
  valtozo:any;
  setValtozo(variable:any){
    this.valtozo=variable;
  }
}
